<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="/resource/common/taglibs.jsp"%>
<%@ include file="/resource/common/bootstrap.tag"%>
<script type="text/javascript" src="${basePath}/resource/js/term.js"></script>
<style>
.term-body{height:100%;}
.panel{margin-bottom:0px;}
.panel-body{padding:4px;padding-top:7px;}
</style>
<html>
<body class="term-body">
<input type="text" id="text"></input>
<input type="button" onclick="sendMessage()"/>
<div id="msg"></div>
</body>
<script type="text/javascript">


<%
	String path=request.getServerName()+":"+request.getServerPort()+request.getContextPath();
%>

var webSocket=new WebSocket('ws:<%=path%>/Websocket?username=1234');

webSocket.onerror = function(event) {
	onError(event);
};

webSocket.onopen = function(event) {
};

webSocket.onmessage = function(event) {
	$("#msg").append(event.data);
};

webSocket.onclose = function(event) {
	onClose(event)
};

function sendMessage(){
	var param={};
	param.from="1234";
	param.to="123";
	param.msg=$("#text").val();
	debugger;
	webSocket.send(JSON.stringify(param));
}

</script>
</html>
